package lab2;
/**
 * Title: Part2GUI class for CSIS 235 Lab 2
 * Description: CS 235 Lab #1 - example program
 *    Basic object oriented GUI program used to show how to draw a shape.
 * 
 * @author Anthony Varghese
 * @email anthony.varghese@uwrf.edu
 * @date September 6th 2012
 */
import javax.swing.JFrame;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.Rectangle2D;
import java.awt.geom.Ellipse2D;

public class Part2GUI extends JFrame {

	/**
	 * main method - this is a smaller main method
	 * @param args
	 */
	public static void main(String[] args) {
		new Part2GUI( FRAME_LOCATION_X, FRAME_LOCATION_Y );
		/*
		 * When we use an object oriented style, it becomes easy to
		 *  to make multiple windows. To see this, uncomment the line 
		 *  below and run. Can we do this with ASimpleGUI?
		 */
		// new Part2GUI( FRAME_LOCATION_X+FRAME_SIZE_X, FRAME_LOCATION_Y );
	}


	/*
	 * Data members used to initialize a window.
	 */
	private static final String TITLE = "Lab 2: A more object-oriented GUI program";
	private static final int FRAME_LOCATION_X = 100;
	private static final int FRAME_LOCATION_Y = 200;
	private static final int FRAME_SIZE_X     = 400;
	private static final int FRAME_SIZE_Y     = 300;
	
	/*
	 * Data members used to set the sizes of shapes to
	 * be drawn inside the window.
	 */
	private Shape shape;
	private static final float SHAPE_LOCATION_X = 150.0f;
	private static final float SHAPE_LOCATION_Y = 75.0f;
	private static final float SHAPE_SIZE_X     = 200.0f;
	private static final float SHAPE_SIZE_Y     = 100.0f;

	
	/**
	 * Constructor - takes care of creating the window
	 *  and the shape we want to draw in it.
	 */
	public Part2GUI( int x, int y) {
		// Set up the title, location and size of the window
		super( TITLE);
		setLocation( x, y );
		setSize( FRAME_SIZE_X, FRAME_SIZE_Y );
		setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		setVisible( true );

		/* At this point, the window should be visible and we are ready to draw shapes. */
		shape = new Rectangle2D.Float( SHAPE_LOCATION_X, SHAPE_LOCATION_Y, SHAPE_SIZE_X, SHAPE_SIZE_Y );

		/* Pause the program for a second */
		try { Thread.sleep( 1000 /* milliseconds */ ); } catch (InterruptedException e) {	}
		
		/*
		 * Let's draw an oval shape. We have to create the new shape and add it to the
		 * "drawing area" and ask the window to repaint itself - Swing will cause
		 * the DrawArea to "refresh" itself.
		 */
		shape = new Ellipse2D.Float( SHAPE_LOCATION_X, SHAPE_LOCATION_Y, SHAPE_SIZE_X, SHAPE_SIZE_Y );
		repaint();

		/*
		 *  Here's where you want to add code to to draw two more new shapes.
		 */

				
		
		/*
		 *  And, finally, add code that will make the shapes move around smoothly
		 *   for about 5 seconds inside the window
		 */
		
		

	}

	/**
	 * The paint method is called whenever the Java runtime system thinks
	 * it needs to draw or redraw something.
	 */
	public void paint(Graphics g){
		super.paint(g);
		Graphics2D g2d = (Graphics2D) g;
		g2d.draw( shape );
	}
}